home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / addzip / quickzip.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-05-19  |  11.3 KB  |  324 lines

  1. VERSION 2.00
  2. Begin Form frmQuickZIP 
  3.    BackColor       =   &H00000000&
  4.    Caption         =   "QuickZIP"
  5.    ClientHeight    =   3645
  6.    ClientLeft      =   1410
  7.    ClientTop       =   1890
  8.    ClientWidth     =   6840
  9.    Height          =   4335
  10.    Icon            =   QUICKZIP.FRX:0000
  11.    Left            =   1350
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   243
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   456
  16.    Top             =   1260
  17.    Width           =   6960
  18.    Begin PictureBox picStatusBar 
  19.       BackColor       =   &H00C0C0C0&
  20.       BorderStyle     =   0  'None
  21.       Height          =   495
  22.       Left            =   120
  23.       ScaleHeight     =   33
  24.       ScaleMode       =   3  'Pixel
  25.       ScaleWidth      =   81
  26.       TabIndex        =   1
  27.       Top             =   2760
  28.       Width           =   1215
  29.       Begin Label lblStatusBar 
  30.          BackColor       =   &H00C0C0C0&
  31.          Caption         =   "Label1"
  32.          FontBold        =   0   'False
  33.          FontItalic      =   0   'False
  34.          FontName        =   "MS Sans Serif"
  35.          FontSize        =   8.25
  36.          FontStrikethru  =   0   'False
  37.          FontUnderline   =   0   'False
  38.          Height          =   255
  39.          Left            =   120
  40.          TabIndex        =   3
  41.          Top             =   120
  42.          Width           =   1215
  43.       End
  44.    End
  45.    Begin TextBox txtZIP 
  46.       Height          =   285
  47.       Left            =   120
  48.       TabIndex        =   2
  49.       Text            =   "Text1"
  50.       Top             =   3120
  51.       Visible         =   0   'False
  52.       Width           =   3255
  53.    End
  54.    Begin ColumnListbox colArchive 
  55.       Height          =   2655
  56.       Left            =   0
  57.       TabIndex        =   0
  58.       Top             =   960
  59.       Width           =   4530
  60.    End
  61.    Begin Menu mnuArchive 
  62.       Caption         =   "&Archive"
  63.       Begin Menu mnuArchiveNew 
  64.          Caption         =   "&New"
  65.       End
  66.       Begin Menu mnuArchiveOpen 
  67.          Caption         =   "&Open..."
  68.       End
  69.       Begin Menu mnuArchiveSep1 
  70.          Caption         =   "-"
  71.       End
  72.       Begin Menu mnuArchiveExit 
  73.          Caption         =   "E&xit"
  74.       End
  75.    End
  76.    Begin Menu mnuOptions 
  77.       Caption         =   "&Options"
  78.       Begin Menu mnuOptionsCompression 
  79.          Caption         =   "&Compression..."
  80.          Begin Menu mnuOptionsCompressionLevel 
  81.             Caption         =   "N&one"
  82.             Index           =   0
  83.          End
  84.          Begin Menu mnuOptionsCompressionLevel 
  85.             Caption         =   "&Minimum"
  86.             Index           =   1
  87.          End
  88.          Begin Menu mnuOptionsCompressionLevel 
  89.             Caption         =   "&Normal"
  90.             Checked         =   -1  'True
  91.             Index           =   2
  92.          End
  93.          Begin Menu mnuOptionsCompressionLevel 
  94.             Caption         =   "Ma&ximum"
  95.             Index           =   3
  96.          End
  97.       End
  98.       Begin Menu mnuOptionsStoreFull 
  99.          Caption         =   "Store full filename"
  100.          Checked         =   -1  'True
  101.       End
  102.       Begin Menu mnuOptionsSep1 
  103.          Caption         =   "-"
  104.       End
  105.       Begin Menu mnuOptionsExtractTo 
  106.          Caption         =   "Extract to..."
  107.       End
  108.       Begin Menu mnuOptionsSep2 
  109.          Caption         =   "-"
  110.       End
  111.       Begin Menu mnuOptionsOnTop 
  112.          Caption         =   "Always on top"
  113.          Checked         =   -1  'True
  114.       End
  115.    End
  116.    Begin Menu mnuHelp 
  117.       Caption         =   "&Help"
  118.       Begin Menu mnuHelpAbout 
  119.          Caption         =   "About..."
  120.       End
  121.    End
  122.    Begin Menu mnuPopUp 
  123.       Caption         =   "PopUp"
  124.       Visible         =   0   'False
  125.       Begin Menu mnuPopSelect 
  126.          Caption         =   "&Select all"
  127.          Enabled         =   0   'False
  128.          Index           =   0
  129.       End
  130.       Begin Menu mnuPopSelect 
  131.          Caption         =   "&Deselect all"
  132.          Enabled         =   0   'False
  133.          Index           =   1
  134.       End
  135.       Begin Menu mnuPopSelect 
  136.          Caption         =   "&Invert selection"
  137.          Enabled         =   0   'False
  138.          Index           =   2
  139.       End
  140.       Begin Menu mnuPopSep1 
  141.          Caption         =   "-"
  142.       End
  143.       Begin Menu mnuPopExtract 
  144.          Caption         =   "&Extract"
  145.          Enabled         =   0   'False
  146.       End
  147.    End
  148. Option Explicit
  149. Sub colArchive_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  150.     If (Button = 2) Then
  151.         If (colArchive.ListCount > 0) Then mnuPopSelect(0).Enabled = True
  152.         If (colArchive.SelectedCount > 0) Then
  153.             mnuPopExtract.Enabled = True
  154.             mnuPopSelect(1).Enabled = True
  155.             mnuPopSelect(2).Enabled = True
  156.         End If
  157.         PopupMenu mnuPopUp
  158.     End If
  159. End Sub
  160. Sub Form_Load ()
  161.     Dim I As Integer
  162.     g_cExtract = App.Path
  163.     colArchive.ColumnCount = 5
  164.     colArchive.ColumnHeading(0) = "Filename"
  165.     colArchive.ColumnWidth(0) = TextWidth("WWWWWWWW.WWW")
  166.     colArchive.ColumnHeading(1) = "Size"
  167.     colArchive.ColumnJustification(1) = TA_RIGHT
  168.     colArchive.ColumnAutoSort(1) = SORT_NUMERIC
  169.     colArchive.ColumnHeading(2) = "Compressed"
  170.     colArchive.ColumnJustification(2) = TA_RIGHT
  171.     colArchive.ColumnAutoSort(2) = SORT_NUMERIC
  172.     colArchive.ColumnHeading(3) = "Ratio"
  173.     colArchive.ColumnWidth(3) = TextWidth("Ratio") + 5
  174.     colArchive.ColumnJustification(3) = TA_RIGHT
  175.     colArchive.ColumnAutoSort(3) = SORT_NUMERIC
  176.     colArchive.ColumnHeading(4) = "Path"
  177.     colArchive.MultiSelect = True
  178.     If (Command$ <> "") Then ListArchiveContents (Command$)
  179.     UpdateStatusBar
  180.     '
  181.     I = addZIP_SetParentWindowHandle(Me.hWnd)
  182.     I = addUNZIP_SetParentWindowHandle(Me.hWnd)
  183.     I = addZIP_SetWindowHandle(txtZIP.hWnd)
  184.     I = addUNZIP_SetWindowHandle(txtZIP.hWnd)
  185.     Me.Show
  186.     SpyMessages
  187. End Sub
  188. Sub Form_Resize ()
  189.     Dim I As Integer
  190.     ' resize the column list box
  191.     colArchive.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight - (TextHeight("lq") + 10)
  192.     ' resize the status bar
  193.     picStatusBar.Move 0, colArchive.Height, colArchive.Width, TextHeight("lq") + 10
  194.     ' set window position - needed when windows is minimised
  195.     If (mnuOptionsOnTop.Checked = True) Then
  196.         I = SetWindowPos(Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  197.     End If
  198. End Sub
  199. Sub Form_Unload (Cancel As Integer)
  200.     End ' the program is closing
  201. End Sub
  202. Sub mnuArchiveExit_Click ()
  203.     End
  204. End Sub
  205. Sub mnuArchiveNew_Click ()
  206.     Load frmUtility
  207.     frmUtility.Caption = "Enter new archive name"
  208.     frmUtility.txtInput.Text = ""
  209.     'frmUtility.txtInput.SetFocus
  210.     frmUtility.Show 1
  211.     If (g_cTemp <> "") Then ListArchiveContents (g_cTemp)
  212. End Sub
  213. Sub mnuOptionsCompressionLevel_Click (Index As Integer)
  214.     Dim I As Integer
  215.     For I = 0 To 3
  216.         mnuOptionsCompressionLevel(I).Checked = False
  217.     Next I
  218.     mnuOptionsCompressionLevel(Index).Checked = True
  219. End Sub
  220. Sub mnuOptionsExtractTo_Click ()
  221.     Load frmUtility
  222.     frmUtility.Caption = "Set extract directory"
  223.     frmUtility.txtInput.Text = g_cExtract
  224.     'frmUtility.txtInput.SetFocus
  225.     frmUtility.txtInput.SelStart = 0
  226.     frmUtility.txtInput.SelLength = Len(g_cExtract)
  227.     frmUtility.Show 1
  228.     If (g_cTemp <> "") Then g_cExtract = g_cTemp
  229. End Sub
  230. Sub mnuOptionsOnTop_Click ()
  231.     Dim I As Integer
  232.     mnuOptionsOnTop.Checked = Not mnuOptionsOnTop.Checked
  233.     If (mnuOptionsOnTop.Checked = True) Then
  234.         I% = SetWindowPos(Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  235.     Else
  236.         I% = SetWindowPos(Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
  237.     End If
  238. End Sub
  239. Sub mnuOptionsStoreFull_Click ()
  240.     mnuOptionsStoreFull.Checked = Not mnuOptionsStoreFull.Checked
  241. End Sub
  242. Sub mnuPopExtract_Click ()
  243.     Dim I As Integer
  244.     Dim J As Integer
  245.     Dim cMessage As String
  246.     Dim cFilename As String
  247.     cMessage = "Do you want to extract the "
  248.     cMessage = cMessage & Format$(colArchive.SelectedCount)
  249.     cMessage = cMessage & " selected files to "
  250.     cMessage = cMessage & g_cExtract & "?"
  251.     If (MsgBox(cMessage, 36, "Confirm") = 6) Then
  252.       For J = 1 To colArchive.ListCount
  253.         If (colArchive.Selected(J - 1) <> False) Then
  254.           I = addUNZIP_ArchiveName(g_cArchiveName)
  255.           cFilename = GetPiece((colArchive.List(J - 1)), Chr$(9), 5) & "/" & GetPiece((colArchive.List(J - 1)), Chr$(9), 1)
  256.           I = addUNZIP_Include(cFilename)
  257.           I = addUNZIP_ExtractTo(g_cExtract)
  258.           I = addUNZIP()
  259.         End If
  260.       Next J
  261.     End If
  262. End Sub
  263. Sub mnuPopSelect_Click (Index As Integer)
  264.   Dim I As Integer
  265.   Select Case Index
  266.     Case 0 ' select all
  267.       For I = 1 To colArchive.ListCount
  268.         colArchive.Selected(I - 1) = True
  269.       Next I
  270.     Case 1 ' deselect all
  271.       For I = 1 To colArchive.ListCount
  272.         colArchive.Selected(I - 1) = False
  273.       Next I
  274.     Case 2 ' invert selection
  275.       For I = 1 To colArchive.ListCount
  276.         colArchive.Selected(I - 1) = Not colArchive.Selected(I - 1)
  277.       Next I
  278.   End Select
  279. End Sub
  280. Sub picStatusBar_Paint ()
  281.     ' Paint 3D effect of Status Bar
  282.     picStatusBar.Line (0, 0)-(picStatusBar.ScaleWidth, 0), RGB(255, 255, 255)
  283.     picStatusBar.Line (0, picStatusBar.ScaleHeight - 2)-(picStatusBar.ScaleWidth, picStatusBar.ScaleHeight - 2), RGB(128, 128, 128)
  284.     picStatusBar.Line (0, picStatusBar.ScaleHeight - 1)-(picStatusBar.ScaleWidth, picStatusBar.ScaleHeight - 1), RGB(0, 0, 0)
  285.     ' Resize label for status bar text
  286.     lblStatusBar.Move 5, 5, picStatusBar.ScaleWidth - 10, TextHeight("lq")
  287.     ' Paint 3D effect for status bar text
  288.     picStatusBar.Line (4, 4)-Step(lblStatusBar.Width + 2, 0), RGB(128, 128, 128)
  289.     picStatusBar.Line (4, 4)-Step(0, lblStatusBar.Height + 2), RGB(128, 128, 128)
  290.     picStatusBar.Line (4, lblStatusBar.Height + 6)-Step(lblStatusBar.Width + 2, 0), RGB(255, 255, 255)
  291.     picStatusBar.Line (4 + lblStatusBar.Width + 2, 4)-Step(0, lblStatusBar.Height + 2), RGB(255, 255, 255)
  292. End Sub
  293. Sub picStatusBar_Resize ()
  294.     ' Need to refresh the picture box because reducing its size
  295.     ' doesnt generate a paint event
  296.     picStatusBar.Refresh
  297. End Sub
  298. Sub txtZIP_Change ()
  299.     Dim cAdditem As String
  300.     Dim cAction As String
  301.     Dim lSize As Long
  302.     Debug.Print txtZIP.Text
  303.     cAction = GetPiece((txtZIP.Text), "|", 2)
  304.     Select Case cAction
  305.         Case "view"
  306.             cAdditem = GetFileName((txtZIP.Text)) & Chr$(9)
  307.             lSize = GetFileOriginalSize((txtZIP.Text))
  308.             g_lSize = g_lSize + lSize
  309.             cAdditem = cAdditem & Str$(lSize) & Chr$(9)
  310.             cAdditem = cAdditem & Str$(GetFileCompressedSize((txtZIP.Text))) & Chr$(9)
  311.             cAdditem = cAdditem & Str$(GetFileCompressionRatio((txtZIP.Text))) & "%" & Chr$(9)
  312.             cAdditem = cAdditem & GetFilePath((txtZIP.Text))
  313.             colArchive.AddItem cAdditem
  314.             g_iCount = g_iCount + 1
  315.         Case "error"
  316.         Case "warning"
  317.         Case Else
  318.             cAdditem = Format$(cAction, ">&&&&&&&&&&&") & " " & GetFileName((txtZIP.Text))
  319.             cAdditem = cAdditem & " - " & Str$(GetFileCompressionRatio((txtZIP.Text))) & "%"
  320.             lblStatusBar.Caption = cAdditem
  321.     End Select
  322.     DoEvents
  323. End Sub
  324.